{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "# Ch01 基础知识"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "source": [
    "## 1.1 交互式解释器"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Hello, world!\n"
     ]
    }
   ],
   "source": [
    "print(\"Hello, world!\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 1.2 算法\n",
    "\n",
    "算法即流程。"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 1.3 数和表达式"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "2 + 2= 4\n5362 + 235253= 240615\n"
     ]
    }
   ],
   "source": [
    "# 加法\n",
    "print(\"2 + 2=\", 2+2)\n",
    "print(\"5362 + 235253=\",5362+235253)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "1 / 2= 0.5\n1 / 1= 1.0\n"
     ]
    }
   ],
   "source": [
    "# 浮点除法\n",
    "print(\"1 / 2=\",1/2)\n",
    "print(\"1 / 1=\",1/1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "1 // 2= 0\n1 // 1= 1\n5.0 // 2.4= 2.0\n"
     ]
    }
   ],
   "source": [
    "# 整型除法\n",
    "print(\"1 // 2=\", 1//2)\n",
    "print(\"1 // 1=\", 1//1)\n",
    "print(\"5.0 // 2.4=\", 5.0//2.4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "1 % 2 = 1\nx % y = x - ((x / /y) * y) -> 1 - ((1 // 2) * 2 = 1\n10 // 3= 3\n10 % 3= 1\n9 // 3= 3\n9 % 3= 0\n2.75 % 0.5= 0.25\n"
     ]
    }
   ],
   "source": [
    "# 求余(求模)运算\n",
    "print(\"1 % 2 =\", 1%2)\n",
    "print(\"x % y = x - ((x / /y) * y) -> 1 - ((1 // 2) * 2 =\", 1-((1//2)*2))\n",
    "print(\"10 // 3=\", 10//3)\n",
    "print(\"10 % 3=\", 10%3)\n",
    "print(\"9 // 3=\", 9//3)\n",
    "print(\"9 % 3=\", 9%3)\n",
    "print(\"2.75 % 0.5=\", 2.75%0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "10 % 3= 1\n10 % -3= -2\n-10 % 3= 2\n-10 % -3= -1\n"
     ]
    }
   ],
   "source": [
    "print(\"10 % 3=\", 10%3)\n",
    "print(\"10 % -3=\", 10%-3)\n",
    "print(\"-10 % 3=\", -10%3)\n",
    "print(\"-10 % -3=\", -10%-3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "10 // 3= 3\n10 // -3= -4\n-10 // 3= -4\n-10 // -3= 3\n"
     ]
    }
   ],
   "source": [
    "print(\"10 // 3=\", 10//3)\n",
    "print(\"10 // -3=\", 10//-3)\n",
    "print(\"-10 // 3=\", -10//3)\n",
    "print(\"-10 // -3=\", -10//-3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "3 ** 2= 9\n-3 ** 2= -9\n(-3) ** 2= 9\n"
     ]
    }
   ],
   "source": [
    "# 乘方(求幂)运算符\n",
    "print(\"3 ** 2=\", 3**2)\n",
    "print(\"-3 ** 2=\", -3**2)\n",
    "print(\"(-3) ** 2=\", (-3)**2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "0xA = 10\n0o10 = 8\n0b1010 = 10\n"
     ]
    }
   ],
   "source": [
    "# 十六进制\n",
    "print(\"0xA =\",0xA)\n",
    "# 八进制\n",
    "print(\"0o10 =\",0o10)\n",
    "# 二进制\n",
    "print(\"0b1010 =\",0b1010)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 1.4变量\n",
    "变量是表示(或者指向)特定值的名称。"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "x * 2= 6\n"
     ]
    }
   ],
   "source": [
    "# 赋值\n",
    "x=3\n",
    "print(\"x * 2=\", x*2)"
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 1.5 语句"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "2*2 = 4\n"
     ]
    }
   ],
   "source": [
    "print(\"2*2 =\",2*2)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 1.6 获取用户输入"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "x= love\n"
     ]
    }
   ],
   "source": [
    "x = input(\"The meaning of life: \")\n",
    "print(\"x=\",x)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "## 1.7 函数\n",
    "\n",
    "函数，内置，定义，调用，参数。"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "2 ** 3= 8\npow(2,3)= 8\n10+pow(2,3*5)/3.0= 10932.666666666666\nabs(-10)= 10\n2 // 3= 0\nround(2/3)= 1\n"
     ]
    }
   ],
   "source": [
    "print(\"2 ** 3=\", 2**3)\n",
    "print(\"pow(2,3)=\", pow(2,3))\n",
    "print(\"10+pow(2,3*5)/3.0=\",10+pow(2,3*5)/3.0)\n",
    "print(\"abs(-10)=\", abs(-10))\n",
    "print(\"2 // 3=\",2 // 3)\n",
    "print(\"round(2/3)=\",round(2/3))"
   ]
  },
  {
   "source": [
    "## 1.8 模块\n",
    "模块，导入。"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "math.floor(32.9)= 32\nint(32.9)= 32\nmath.ceil(32.3)= 33\nmath.ceil(32)= 32\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "print(\"math.floor(32.9)=\",math.floor(32.9))\n",
    "print(\"int(32.9)=\",int(32.9))\n",
    "print(\"math.ceil(32.3)=\",math.ceil(32.3))\n",
    "print(\"math.ceil(32)=\",math.ceil(32))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "sqrt(9)= 3.0\n"
     ]
    }
   ],
   "source": [
    "from math import sqrt\n",
    "print(\"sqrt(9)=\",sqrt(9))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 1.8.1 cmath和复数\n",
    "\n",
    "注意：nan 具有特殊含义，指的是「非数值」(not a number)"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# ValueError\n",
    "from math import sqrt\n",
    "# print(\"sqrt(-1)=\",sqrt(-1))"
   ]
  },
  {
   "cell_type": "code",
   "source": [
    "import math,cmath\n",
    "# math.sqrt(-1)\n",
    "print(\"cmath.sqrt(-1) =\",cmath.sqrt(-1))\n",
    "print(\"(1+3j)*(9+4j) =\",(1+3j)*(9+4j))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% \n",
     "is_executing": false
    }
   },
   "execution_count": 17,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "cmath.sqrt(-1) = 1j\n",
      "(1+3j)*(9+4j) = (-3+31j)\n"
     ]
    }
   ]
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 1.8.2 回到未来\n",
    "`from __future__ import division`：导入 Python 当前不支持，但是未来可能支持的功能"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "source": [
    "## 1.9 保存并且执行程序\n",
    "\n",
    "PyCharm 或者 VSCode。"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [],
   "source": [
    "from turtle import *\n",
    "forward(100)\n",
    "left(120)\n",
    "forward(100)\n",
    "left(120)\n",
    "forward(100)"
   ]
  },
  {
   "source": [
    "### 1.9.1 命令行运行\n",
    "`python hello.py`"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "### 1.9.2 让脚本像程序一样运行\n",
    "\n",
    "如果安装了 Python 解释器，则Unix支持其像脚本一样运行。\n",
    "\n",
    "```bash\n",
    "$ !/usr/bin/env python\n",
    "$ chmod a+x hello.py\n",
    "$ hello.py\n",
    "```\n",
    "\n",
    "如果安装了 Python 解释器，则 Windows 双击扩展名 .py 的程序即可以运行。"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "### 1.9.3 注释\n",
    "\n",
    "井号（#）：用来注释"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "## 1.10 字符串\n",
    "\n",
    "字符串 ( string )：表示一段文本。"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "source": [
    "### 1.10.1 单引号 与 双引号字符串\n",
    "\n",
    "单引号与双引号没有区别，可以使用某种引号将另一种引号包含在字符串中使用。"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "I'm a student.\n"
     ]
    }
   ],
   "source": [
    "print(\"I'm a student.\")"
   ]
  },
  {
   "source": [
    "### 1.10.1 引号转义\n",
    "\n",
    "使用反斜杠（\\）对各种功能符号进行转义。"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "\"Hello, world!\" she said.\n"
     ]
    }
   ],
   "source": [
    "print(\"\\\"Hello, world!\\\" she said.\")"
   ]
  },
  {
   "source": [
    "### 1.10.2 拼接字符串\n",
    "\n",
    "字符串相加：\"Hello,\" + \" world!\""
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Let's say \"Hello world!\"\n"
     ]
    }
   ],
   "source": [
    "print(\"Let's say \" '\"Hello world!\"')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Hello, world!\nHello, world!\n"
     ]
    }
   ],
   "source": [
    "x=\"Hello, \"\n",
    "y=\"world!\"\n",
    "print(x+y)\n",
    "print(\"Hello, \"+\"world!\")"
   ]
  },
  {
   "source": [
    "### 1.10.3 字符串表示\n",
    "\n",
    "str()：得到字符串的正确显示。\n",
    "\n",
    "repr()：得到字符串的正确的值。"
   ],
   "cell_type": "markdown",
   "metadata": {}
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "Hello,\nworld!\n'Hello,\\nworld!'\n"
     ]
    }
   ],
   "source": [
    "print(str(\"Hello,\\nworld!\"))\n",
    "\n",
    "print(repr(\"Hello,\\nworld!\"))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### 1.10.4 长字符串\n",
    "#### 1.长字符串：跨越多行的字符串，可以使用三引号。"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "This is a very long string.\nIt continues here.\nAnd it's not over yet.\n\"Hello, world!\nStill here.\n中文也可以\n我说：“这些都可以！”\n\n"
     ]
    }
   ],
   "source": [
    "print('''This is a very long string.\n",
    "It continues here.\n",
    "And it's not over yet.\n",
    "\"Hello, world!\n",
    "Still here.\n",
    "中文也可以\n",
    "我说：“这些都可以！”\n",
    "''')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "#### 2.原始字符串\n",
    "原始字符串：避免字符转义。\n",
    "\n",
    "原始字符串不能以单斜杠结尾。"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "C:\\Program Files\\Java\\jre1.8.0_202\\bin\\server\\Xusage.txt\nC:\\Program Files\\\n"
     ]
    }
   ],
   "source": [
    "print(r\"C:\\Program Files\\Java\\jre1.8.0_202\\bin\\server\\Xusage.txt\")\n",
    "# print(r\"C:\\Program Files\\\")   # 错误的用法\n",
    "print(r\"C:\\Program Files\"\"\\\\\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "### Unicode, bytes, bytearray\n",
    "\n",
    "每个Unicode都用一个码点（Code Point）表示，而码点是Unicode标准给每个字符指定的数字。"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "\\u00C6 = Æ\n\\U0001F60A = 😊\nThis is a cat: \\N{Cat} = 🐈\n"
     ]
    }
   ],
   "source": [
    "print(\"\\\\u00C6 = \\u00C6\")\n",
    "print(\"\\\\U0001F60A = \\U0001F60A\")\n",
    "print(\"This is a cat: \\\\N{Cat} = \\N{Cat}\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "直接创建 bytes 对象，而不是字符串。"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "b'Hello, world!'\nb'Hello, world!'\nb'Hello, world!'\nb'\\xff\\xfe\\x00\\x00H\\x00\\x00\\x00e\\x00\\x00\\x00l\\x00\\x00\\x00l\\x00\\x00\\x00o\\x00\\x00\\x00,\\x00\\x00\\x00 \\x00\\x00\\x00w\\x00\\x00\\x00o\\x00\\x00\\x00r\\x00\\x00\\x00l\\x00\\x00\\x00d\\x00\\x00\\x00!\\x00\\x00\\x00'\n13\n56\nb'\\xe4\\xbd\\xa0\\xe5\\xa5\\xbd\\xef\\xbc\\x8c\\xe4\\xb8\\x96\\xe7\\x95\\x8c\\xef\\xbc\\x81'\nb''\nb'??????'\nb'\\\\u4f60\\\\u597d\\\\uff0c\\\\u4e16\\\\u754c\\\\uff01'\nb'&#20320;&#22909;&#65292;&#19990;&#30028;&#65281;'\nb'\\xe4\\xbd\\xa0\\xe5\\xa5\\xbd\\xef\\xbc\\x8c\\xe4\\xb8\\x96\\xe7\\x95\\x8c\\xef\\xbc\\x81'\n你好，世界！\nb'\\xe4\\xbd\\xa0\\xe5\\xa5\\xbd\\xef\\xbc\\x8c\\xe4\\xb8\\x96\\xe7\\x95\\x8c\\xef\\xbc\\x81'\n你好，世界！\n"
     ]
    }
   ],
   "source": [
    "print(b'Hello, world!')\n",
    "print('Hello, world!'.encode(\"ASCII\"))\n",
    "print('Hello, world!'.encode(\"UTF-8\"))\n",
    "print('Hello, world!'.encode(\"UTF-32\"))\n",
    "\n",
    "print(len('Hello, world!'.encode(\"UTF-8\")))\n",
    "print(len('Hello, world!'.encode(\"UTF-32\")))\n",
    "\n",
    "# print(\"你好，世界！\".encode(\"ASCII\"))   # 中文无法使用 ASCII 编码\n",
    "print(\"你好，世界！\".encode(\"UTF-8\"))\n",
    "\n",
    "print(\"你好，世界！\".encode(\"ASCII\",'ignore'))\n",
    "print(\"你好，世界！\".encode(\"ASCII\",'replace'))\n",
    "print(\"你好，世界！\".encode(\"ASCII\",'backslashreplace'))\n",
    "print(\"你好，世界！\".encode(\"ASCII\",'xmlcharrefreplace'))\n",
    "\n",
    "print(\"你好，世界！\".encode())\n",
    "print(b'\\xe4\\xbd\\xa0\\xe5\\xa5\\xbd\\xef\\xbc\\x8c\\xe4\\xb8\\x96\\xe7\\x95\\x8c\\xef\\xbc\\x81'.decode())\n",
    "print(bytes(\"你好，世界！\",encoding = 'utf-8'))\n",
    "print(str(b'\\xe4\\xbd\\xa0\\xe5\\xa5\\xbd\\xef\\xbc\\x8c\\xe4\\xb8\\x96\\xe7\\x95\\x8c\\xef\\xbc\\x81',encoding='utf-8'))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "bytearray 是 bytes 的可变版本。\n",
    "ord()获取字符的ASCII值。"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "outputs": [
    {
     "output_type": "execute_result",
     "data": {
      "text/plain": [
       "bytearray(b'Hullo!')"
      ]
     },
     "metadata": {},
     "execution_count": 17
    }
   ],
   "source": [
    "x=bytearray(b'Hello!')\n",
    "x[1]=ord(b'u')\n",
    "x\n",
    "# ord(b'中') # 必须是ASCII字符"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "小结\n",
    "----\n",
    "\n",
    "- 算法：如何完成特定的任务。\n",
    "  - 程序：计算机的实现，主要由表达式和语句组成。\n",
    "- 表达式：结果为一个值。\n",
    "  - 包括：运算符、函数、变量\n",
    "- 变量：表示值的名称。需要赋值。\n",
    "- 语句：计算机执行的操作的指示。\n",
    "- 函数：接受参数，返回结果。\n",
    "- 模块：对功能的扩展。\n",
    "- 字符串：一段文本。\n",
    "\n",
    "### 函数列表\n",
    "\n",
    "- abs(number)：绝对值\n",
    "- bytes(string, encoding[, errors])：指定的字符串进行编码，指定的方式处理错误。\n",
    "- cmath.sqrt(number)：返回平方根。可以处理负数。\n",
    "- float(object)：转换成浮点数。\n",
    "- help([object])：提供交互式帮助。\n",
    "- input(prompt)：以字符串的方式获取用户输入。\n",
    "- int(object)：转换成整数。\n",
    "- math.ceil(number)：以浮点数的方式返回向上圆整的结果。\n",
    "- math.floor(number)：以浮点数的方式返回向下圆整的结果。\n",
    "- math.sqrt(number)：返回平方根。不可以处理负数。\n",
    "- pow(x, y[, z])：返回x的y次方对z求模的结果。\n",
    "- print(object, ...)：打印参数，以空格分隔。\n",
    "- repr(object)：返回指定值的字符串表示。\n",
    "- round(number[, ndigits])：四舍五入为指定的精度，正好为五时舍入到偶数。\n",
    "- str(object)：转换为字符串。"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%% md\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": [
      "pow(3,2,5) = 4\n",
      "round(3.25) = 3.2\n",
      "round(3.35) = 3.4\n"
     ]
    }
   ],
   "source": [
    "print(\"pow(3,2,5) =\",pow(3,2,5))\n",
    "print(\"round(3.25) =\",round(3.25,1))\n",
    "print(\"round(3.35) =\",round(3.35,1))"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n",
     "is_executing": false
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "name": "python3",
   "display_name": "Python 3.7.0 64-bit (conda)",
   "metadata": {
    "interpreter": {
     "hash": "b3ba2566441a7c06988d0923437866b63cedc61552a5af99d1f4fb67d367b25f"
    }
   }
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "3.7.0-final"
  },
  "pycharm": {
   "stem_cell": {
    "cell_type": "raw",
    "source": [],
    "metadata": {
     "collapsed": false
    }
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}